package com.tqfframe.website.web.aspet;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

/**
 * @Author: 唐祺峰
 * @Date: 2022/2/15 0015 13:38
 * @Version 1.0
 */
@Aspect
@Component
public class TestIntercept {

    //切入点execution()方法参数级别
    @Pointcut("execution(public * com.tqfframe.website.web.controller.*.*(..))")
    public void recordLog(){}

    //通知方法
    @Around("recordLog()")
    public Object around(ProceedingJoinPoint pjp) throws Throwable{
        this.printLog("已经记录下操作日志@Around 方法执行前");
//        pjp.proceed();
        TestCallback testCallback= pjp::proceed;
        System.out.println("这里写一些业务操作");
        Object object=testCallback.call();
        this.printLog("已经记录下操作日志@Around 方法执行后");
        return object;
    }

    private void printLog(String str){
        System.out.println(str);
    }
}
